package breeze.pixel.weather.moretool.panelmode;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;

import breeze.pixel.weather.R;
import brz.breeze.app_utils.BActivity;

public class PannelAddTaskActivity extends BActivity {

    private EditText mEdittext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pannel_add_task);
        init();

    }

    @Override
    public void init() {
        mEdittext = find(R.id.panel_addtask_edit);
    }

    @Override
    public void initData() {

    }

    public void save(View view) {
        String content = mEdittext.getText().toString();
        if (TextUtils.isEmpty(content)){
            toast("请填写内容");
        }else{
            String[] tasks = content.split("\n");
            Intent intent = new Intent();
            intent.putExtra("tasks", tasks);
            this.setResult(RESULT_OK, intent);
            finish();
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK){
            this.setResult(RESULT_CANCELED);
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}